listbox test: Only compare values for rows we have
authorTimm Bäder <mail@baedert.org>
Thu, 15 Oct 2020 04:07:12 +0000 (06:07 +0200)
committerTimm Bäder <mail@baedert.org>
Thu, 22 Oct 2020 15:46:33 +0000 (17:46 +0200)
This shouldn't happen, but don't compare 100 values if we didnt' get 100
values from the listbox.

testsuite/gtk/listbox.c

index a5c895235c0e4da9574382f1589ba6e35a9c6559..815cf4b031474784364a814eb2a52518f39e60f5 100644 (file)
@@ -26,6 +26,7 @@ check_sorted (GtkListBox *list)
   GtkWidget *row, *label;
   int res[100];
   int index, value;
+  int n_rows = 0;
   int i;
 
   for (row = gtk_widget_get_first_child (GTK_WIDGET (list));
@@ -39,10 +40,11 @@ check_sorted (GtkListBox *list)
       label = gtk_list_box_row_get_child (GTK_LIST_BOX_ROW (row));
       value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), "data"));
       res[index] = value;
+      n_rows++;
     }
 
-  for (i = 1; i < 100; i++)
-    g_assert (res[i - 1] <= res[i]);
+  for (i = 1; i < n_rows; i++)
+    g_assert_cmpint (res[i - 1], <=, res[i]);
 }
 
 static void